/**
 * type: 0 字符串 1 数组 -1 bit数据
 * 
 */


const BLE_DATA = {
	SOI: "7F",
	ADD: "10",
	VER: "02",
	cmdArrs: [{
		FUN: "12",
		params: [{
			len: 4,
			type: -1, // 字节数组
			name: "PackStatus",
			text: "系统状态"
		}, {
			len: 2,
			type: 0, //默认数据类型
			name: "CurCadc",
			text: "电流"
		}, {
			len: 1,
			type: 0, //默认数据类型
			name: "VCellNum",
			text: "电池串数"
		}, {
			len: 32,
			type: 1, //数组类型
			name: "VCell",
			text: "电芯电压"
		}, {
			len: 2,
			type: 0,
			name: "JH",
			text: "平衡是否开启"
		}, {
			len: 1,
			type: 0,
			name: "DXWG",
			text: "电芯温感数量"
		}, {
			len: 2,
			type: 1,
			name: "DX",
			text: "电芯温感温度"
		}, {
			len: 1,
			type: 0,
			name: "MOS",
			text: "MOS温感数量"
		}, {
			len: 1,
			type: 0,
			name: "MOSTemp",
			text: "MOS温度"
		}, {
			len: 2,
			type: 0,
			name: "num",
			text: "充放电次数"
		}, {
			len: 2,
			type: 0,
			name: "RC",
			text: "剩余容量"
		}, {
			len: 2,
			type: 0,
			name: "FCC",
			text: "电池满容量"
		}, {
			len: 1,
			type: 0,
			name: "MOSCtrl",
			text: "C0 表示充放电都通"
		}, ]
	}, {
		FUN: "11",
		params: [{
			len: 1,
			type: -1, // 字节数组
			name: "status1",
			text: "电池状态"
		}, {
			len: 1,
			type: -1, // 字节数组
			name: "status2",
			text: "电池状态"
		}, {
			len: 1,
			type: -1, // 字节数组
			name: "status3",
			text: "电池状态"
		}, {
			len: 1,
			type: -1, // 字节数组
			name: "status4",
			text: "电池状态"
		}, {
			len: 2,
			type: 0, //默认数据类型
			name: "CurCadc",
			text: "电流"
		}, {
			len: 2,
			type: 0, //默认数据类型
			name: "Vmax",
			text: "最高电压"
		}, {
			len: 2,
			type: 1, //数组类型
			name: "Vmin",
			text: "最低电压"
		}, {
			len: 2,
			type: 0,
			name: "Voltage",
			text: "电池总电压"
		}, {
			len: 1,
			type: 0,
			name: "Tmax",
			text: "最高电芯温度"
		}, {
			len: 1,
			type: 0,
			name: "Tmin",
			text: "最低电芯温度"
		}, {
			len: 2,
			type: 0,
			name: "num",
			text: "充放电循环"
		}, {
			len: 2,
			type: 0,
			name: "RC",
			text: "剩余容量"
		}, {
			len: 2,
			type: 0,
			name: "FCC",
			text: "电池满容量"
		}, {
			len: 1,
			type: 0,
			name: "MOSCtrl",
			text: "C0 表示充放电都通"
		}]
	}],
	ctrlCmd: [{
		//读取历史记录
		/**
			* 0x00 表示从第一条记录开始读取。
 			* 0x01表示上一条记录读取正常，继续下一条。
 			* 0x02表示上一条记录读取错误，重读上条记录。
		*/
		FUN: '23',
		params: [{
			len: 1,
			type: 0,
			name: 'statu',
			text: '读取状态' //FF 表示读取错误。00 表示无记录01 表示正常读取 02 表示当前是最后一条记录
		}, {
			len: 6,
			type: 0,
			name: "time",
			text: "记录时间"
		}, {
			len: 2,
			type: 0,
			name: "offTime",
			text: "自动关机计时"
		}, {
			len: 1,
			type: -1, // 字节数组
			name: "status1",
			text: "电池状态"
		}, {
			len: 2,
			type: 0, //默认数据类型
			name: "CurCadc",
			text: "电流"
		}, {
			len: 1,
			type: 0, //默认数据类型
			name: "VCellNum",
			text: "电池串数"
		}, {
			len: 32,
			type: 1, //数组类型
			name: "VCell",
			text: "电芯电压"
		}, {
			len: 2,
			type: 0,
			name: "JH",
			text: "平衡是否开启"
		}, {
			len: 1,
			type: 0,
			name: "DXWG",
			text: "电芯温感数量"
		}, {
			len: 2,
			type: 1,
			name: "DX",
			text: "电芯温感温度"
		}, {
			len: 1,
			type: 0,
			name: "MOS",
			text: "MOS温感数量"
		}, {
			len: 1,
			type: 0,
			name: "MOSTemp",
			text: "MOS温度"
		}, {
			len: 2,
			type: 0,
			name: "num",
			text: "充放电循环"
		}, {
			len: 2,
			type: 0,
			name: "RC",
			text: "剩余容量"
		}, {
			len: 2,
			type: 0,
			name: "FCC",
			text: "电池满容量"
		}, {
			len: 1,
			type: 0,
			name: "MOSCtrl",
			text: "C0 表示充放电都通"
		}]
	}]
}




function getMosState(binaryData) {
	const bitInfo = [{
			name: 'Bit0',
			value: binaryData[0],
			desc: '放电 MOS 强制断开'
		},
		{
			name: 'Bit1',
			value: binaryData[1],
			desc: '充电 MOS 强制断开'
		},
		{
			name: 'Bit2',
			value: binaryData[2],
			desc: '预放电 MOS 状态，1 表示开关闭合，允许预放电。'
		},
		{
			name: 'Bit3',
			value: binaryData[3],
			desc: '预充电 MOS 状态，1 表示开关闭合，允许预充电。'
		},
		{
			name: 'Bit4',
			value: binaryData[4],
			desc: '加热开关状态，1 表示开关闭合，允许加热。'
		},
		{
			name: 'Bit5',
			value: binaryData[5],
			desc: 'ACC 开关状态，1 表示开关闭合，允许闭合充放电 MOS。'
		},
		{
			name: 'Bit6',
			value: binaryData[6],
			desc: '充电开关状态，1 表示开关闭合，允许充电。'
		},
		{
			name: 'Bit7',
			value: binaryData[7],
			desc: '放电开关状态，1 表示开关闭合，允许放电。'
		},
	];
	return bitInfo;
}

function getState1(binaryData) {
	const bitInfo = [{
			name: 'Bit0',
			value: binaryData[0],
			desc: '充电中'
		},
		{
			name: 'Bit1',
			value: binaryData[1],
			desc: '充电过流'
		},
		{
			name: 'Bit2',
			value: binaryData[2],
			desc: ''
		},
		{
			name: 'Bit3',
			value: binaryData[3],
			desc: '充电 MOS 漏电'
		},
		{
			name: 'Bit4',
			value: binaryData[4],
			desc: '放电中'
		},
		{
			name: 'Bit5',
			value: binaryData[5],
			desc: '放电过流'
		},
		{
			name: 'Bit6',
			value: binaryData[6],
			desc: '放电短路'
		},
		{
			name: 'Bit7',
			value: binaryData[7],
			desc: '放电 MOS 漏电'
		},
	];
	return bitInfo;
}


function getState2(binaryData) {
	const bitInfo = [{
			name: 'Bit0',
			value: binaryData[0],
			desc: '电芯侦测线开路'
		},
		{
			name: 'Bit1',
			value: binaryData[1],
			desc: '温感侦测线开路'
		},
		{
			name: 'Bit2',
			value: binaryData[2],
			desc: 'MOS温感侦测线开路'
		},
		{
			name: 'Bit3',
			value: binaryData[3],
			desc: '模拟前端工作异常'
		},
		{
			name: 'Bit4',
			value: binaryData[4],
			desc: '电芯过压'
		},
		{
			name: 'Bit5',
			value: binaryData[5],
			desc: '电芯欠压'
		},
		{
			name: 'Bit6',
			value: binaryData[6],
			desc: '总压过高'
		},
		{
			name: 'Bit7',
			value: binaryData[7],
			desc: '总压过低'
		},
	];
	return bitInfo;
}

function getState3(binaryData) {
	const bitInfo = [{
			name: 'Bit0',
			value: binaryData[0],
			desc: 'MOS 温度超充放电温度上限'
		},
		{
			name: 'Bit1',
			value: binaryData[1],
			desc: 'MOS 温差超充放电温差上限'
		},
		{
			name: 'Bit2',
			value: binaryData[2],
			desc: 'MOS温感侦测线开路'
		},
		{
			name: 'Bit3',
			value: binaryData[3],
			desc: '电芯温度超过充电温度上限'
		},
		{
			name: 'Bit4',
			value: binaryData[4],
			desc: '电芯温度超过放电温度上限'
		},
		{
			name: 'Bit5',
			value: binaryData[5],
			desc: '电芯温度低于充电温度下限'
		},
		{
			name: 'Bit6',
			value: binaryData[6],
			desc: '电芯温度低于放电温度下限'
		},
		{
			name: 'Bit7',
			value: binaryData[7],
			desc: '电芯温差超过放电温度上限。'
		},
	];
	return bitInfo;
}

function getState4(binaryData) {
	const bitInfo = [{
			name: 'Bit0',
			value: binaryData[0],
			desc: '禁止充电'
		},
		{
			name: 'Bit1',
			value: binaryData[1],
			desc: '禁止放电'
		},
		{
			name: 'Bit2',
			value: binaryData[2],
			desc: ''
		},
		{
			name: 'Bit3',
			value: binaryData[3],
			desc: ''
		},
		{
			name: 'Bit4',
			value: binaryData[4],
			desc: ''
		},
		{
			name: 'Bit5',
			value: binaryData[5],
			desc: '压差高于充电允许压差上限'
		},
		{
			name: 'Bit6',
			value: binaryData[6],
			desc: '电芯电压低于充电电压下限'
		},
		{
			name: 'Bit7',
			value: binaryData[7],
			desc: '深度欠压'
		},
	];
	return bitInfo;
}


export default BLE_DATA